package org.lxy.config;

import org.lxy.core.exception.BusException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author 卢心怡
 */
@ControllerAdvice
public class ControllerExceptionConfig {


    @ExceptionHandler(value = BusException.class)
    public ModelAndView exceptionHandler(HttpServletRequest httpServletRequest, BusException e) {
        ModelAndView modelAndView = new ModelAndView(e.getJspName());
        modelAndView.addObject("errorMsg", e.getMessage());
        return modelAndView;
    }
}
